<?php

class NewsController extends Controller
{
	
	public function actionIndex()
	{
		$data = parent::$pageData;
		$this->pageTitle = $data[ 'pageTitle' ] . ' — Моби03';
		Yii::app()->clientScript->registerMetaTag('', 'description');
		Yii::app()->clientScript->registerMetaTag($data[ 'pageTitle' ], 'keywords');
		$criteria = new CDbCriteria();
		$criteria->compare( '"pageActive"', 1 );
		$criteria->compare( '"pageType"', 'news' );
		$criteria->order = '"pageCreateDate" desc';
		$count = Page::model()->count( $criteria );
		$pages = new CPagination( $count );
		$pages->pageSize = 4;
		$pages->applyLimit( $criteria );
		$models = Page::model()->findAll( $criteria );
		$this->render( 'index', array( 'models' => $models, 'pages' => $pages ) );
	}

	public function actionView()
	{
		$data = parent::$pageData;		
		$this->pageTitle = $data['pageTitle'] . ' — Новости — Моби03';
		Yii::app()->clientScript->registerMetaTag('', 'description');
		Yii::app()->clientScript->registerMetaTag($data['pageTitle'], 'keywords');
		$this->render( 'view', array( 'data' => $data ) );
	}

}
